<template>
  <div class="hello">
    <CityHead></CityHead>
    <search :date="cityList"></search>
    <city-content :hotCityList="hotCityList" :cityList="cityList" :keys="key"></city-content>
    <city-list :list="cityList" @change="cityText"></city-list>
  </div>
</template>

<script>
import CityHead from "./city/CityHead";
import search from "./city/search";
import CityContent from "./city/CityContent";
import cityList from "./city/cityList";

import { CityList } from "../api/http";
export default {
  name: "city",
  data() {
    return {
      hotCityList: [],
      cityList: [],
      key: ""
    };
  },
  mounted() {
    CityList()
      .then(res => {
        if (res.status === 200 && res.data.ret) {
          this.hotCityList = res.data.data.hotCities;
          this.cityList = res.data.data.cities;
        }
        // console.log(res);
      })
      .catch(err => {
        console.log(err);
      });
  },
  methods: {
    cityText(key) {
      this.key = key;
      // console.log(key);
    }
  },
  components: { CityHead, search, CityContent, cityList }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>
